﻿package mortal.game.view.platform.platformTencent
{
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import fl.controls.*;
    import fl.data.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.nationalDayAct.*;
    import mortal.game.view.platform.*;
    import mortal.mvc.interfaces.*;

    public class PlatformQQBlueXuFeiPanel extends BaseWindow
    {
        private var _bg:GImageBitmap;
        private var _xufeiBtn:GLoadingButton;
        private var _txt:GTextFiled;
        private var _giftList:GTileList;
        private var _style:int = 2;
        private static var _instance:PlatformQQBlueXuFeiPanel;

        public function PlatformQQBlueXuFeiPanel(param1:ILayer = null)
        {
            super(param1);
            setSize(651, 588);
            title = "QQ蓝钻续费大礼";
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.gImageBitmap(ImagesConst.QQBlueVipXufeiBg, 10, 10 + 24, this);
            this._txt = UIFactory.gTextField("", 72, 20 + 195, 600, 300, this, GlobalStyle.textFormatDanLan.setSize(16).setLeading(8));
            this._txt.mouseEnabled = false;
            this._giftList = UIFactory.tileList(6 + 145, 30 + 222 - 54 + 5 + 166, 500, 80, this);
            this._giftList.columnWidth = 43 + 40;
            this._giftList.rowHeight = 40 + 40;
            this._giftList.setStyle("cellRenderer", nationalDayActGiftCellRender);
            this._giftList.direction = GBoxDirection.HORIZONTAL;
            if (PlatformTencentUtil.isDexulePast())
            {
                this.setDeluxeStyle();
            }
            else if (PlatformTencentUtil.isNormalPast())
            {
                this.setNormalStyle();
            }
            else if (PlatformTencentUtil.canGetFlag)
            {
                this.setCanGetStyle();
            }
            this.refresh();
            return;
        }// end function

        private function onClickHandle(event:MouseEvent) : void
        {
            if (event.target == this._xufeiBtn)
            {
                GameUtil.gotoQQActiveRePay(this._style);
            }
            return;
        }// end function

        private function setCanGetStyle() : void
        {
            this._txt.htmlText = "亲爱的<font color=\'#8979a0\'>" + Cache.instance.role.playerInfo.name + "</font>\n" + "      您已成功续费，可以免费获得价值1200Q币的续费礼包!";
            return;
        }// end function

        private function setNormalStyle() : void
        {
            this._style = 1;
            this._txt.htmlText = "亲爱的<font color=\'#8979a0\'>" + Cache.instance.role.playerInfo.name + "</font>\n" + "      您的<font color=\'#d96350\'>    蓝钻贵族     </font>已经到期，届时将会失去众多蓝钻专属特权," + "\n" + "现在续费蓝钻，还能免费获得价值1200Q币的续费礼包!";
            this._xufeiBtn = UIFactory.gLoadingButton(ResFileConst.QQBlueXufeiBtn, 100 + 151, 486, 130, 37, this);
            this._xufeiBtn.configEventListener(MouseEvent.CLICK, this.onClickHandle);
            return;
        }// end function

        private function setDeluxeStyle() : void
        {
            this._style = 2;
            this._txt.htmlText = "亲爱的<font color=\'#8979a0\'>" + Cache.instance.role.playerInfo.name + "</font>\n" + "      您的<font color=\'#d96350\'>   豪华蓝钻贵族     </font>已经到期，届时将会失去众多蓝钻专属特权," + "\n" + "现在续费蓝钻，还能免费获得价值1200Q币的续费礼包!";
            this._xufeiBtn = UIFactory.gLoadingButton(ResFileConst.QQBlueDeluxeXufeiBtn, 100 + 137, 486, 159, 37, this);
            this._xufeiBtn.configEventListener(MouseEvent.CLICK, this.onClickHandle);
            return;
        }// end function

        public function refresh() : void
        {
            var _loc_1:int = 0;
            this._giftList.dataProvider = this.getGiftListDataProviderByCode(PlatformGiftConfig.instance.xufeiGift.reward);
            this._giftList.x = 6 + 145 + 73 + 100 - 40 - 0.5 * (this._giftList.dataProvider.length * 43);
            this._giftList.drawNow();
            return;
        }// end function

        protected function setBtnCanGetStyle(param1:Button) : void
        {
            if (!param1)
            {
                return;
            }
            param1.mouseEnabled = true;
            param1.filters = [];
            EffectManager.glowFilterReg(param1);
            return;
        }// end function

        protected function setBtnCanNotGetStyle(param1:Button) : void
        {
            if (!param1)
            {
                return;
            }
            param1.mouseEnabled = false;
            EffectManager.glowFilterUnReg(param1);
            param1.filters = [FilterConst.colorFilter3];
            return;
        }// end function

        private function getGiftListDataProviderByCode(param1:int) : DataProvider
        {
            var _loc_5:Array = null;
            var _loc_6:ItemData = null;
            var _loc_9:nationalDayActGiftDataGroup = null;
            var _loc_2:* = new DataProvider();
            var _loc_3:* = new ItemData(param1).itemInfo as ItemGiftBagInfo;
            var _loc_4:* = _loc_3.itemList1.split("&");
            var _loc_7:* = _loc_4.length;
            var _loc_8:int = 0;
            while (_loc_8 < _loc_4.length)
            {
                
                _loc_5 = _loc_4[_loc_8].split("#");
                _loc_6 = new ItemData(int(_loc_5[1]));
                _loc_9 = new nationalDayActGiftDataGroup();
                _loc_9.itemCode = int(_loc_5[1]);
                _loc_9.itemData = _loc_6;
                _loc_9.itemAmount = _loc_5[2];
                _loc_9.isBind = true;
                _loc_2.addItem(_loc_9);
                _loc_8++;
            }
            return _loc_2;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._bg.dispose(param1);
            this._bg = null;
            if (this._xufeiBtn)
            {
                this._xufeiBtn.dispose(param1);
                this._xufeiBtn = null;
            }
            this._txt.dispose(param1);
            this._txt = null;
            this._giftList.dispose(param1);
            this._giftList = null;
            this._style = 2;
            super.disposeImpl(param1);
            return;
        }// end function

        public static function get instance() : PlatformQQBlueXuFeiPanel
        {
            if (!_instance)
            {
                _instance = new PlatformQQBlueXuFeiPanel;
            }
            return _instance;
        }// end function

        public static function hasInstance() : Boolean
        {
            return _instance != null;
        }// end function

        public static function isViewShow() : Boolean
        {
            return hasInstance() && !instance.isHide;
        }// end function

    }
}
